home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / rayshade / Configure < prev    next >
Text File  |  1994-08-01  |  49KB  |  2,229 lines

  1. #! /bin/sh
  2. #
  3. # If these # comments don't work, trim them.  Don't worry about any
  4. # other shell scripts, Configure will trim # comments from them for you.
  5. #
  6. # (If you are trying to port this package to a machine without sh, I'd
  7. # suggest you cut out the prototypical config.h from the end of this
  8. # file and edit it to reflect your system.  Some packages may include
  9. # samples of config.h for certain machines, so you might look for one
  10. # of those.)
  11. #
  12. # Yes, you may rip this off to use in other distribution packages.
  13. # (Note: this Configure script was generated automatically.  Rather than
  14. # working with this copy of Configure, you may wish to get metaconfig.
  15. # Write to ram@educ.emse.fr (Raphael Manfredi) and I will send you
  16. # my version which slightly differs from the original written by
  17. # Larry Wall.)
  18.  
  19. # $Id: Configure,v 4.0.1.1 91/10/10 18:39:55 cek Exp Locker: cek $
  20.  
  21. : save PATH defined by user
  22. user_path=$PATH
  23.  
  24. : sanity checks
  25. PATH='.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin'
  26. PATH=$PATH:'/usr/5bin:/etc:/usr/gnu/bin:/usr/new:/usr/new/bin:/usr/nbin'
  27. PATH=$PATH:'/sys5.3/bin:/sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb'
  28. PATH=$PATH:'/bsd4.3/usr/bin:/usr/bsd'
  29. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)
  30.  
  31. if test ! -t 0; then
  32.     echo "Say 'sh Configure', not 'sh <Configure'"
  33.     exit 1
  34. fi
  35.  
  36. (alias) >/dev/null 2>&1 && \
  37.     echo "(I see you are using the Korn shell.  Some ksh's blow up on Configure," && \
  38.     echo "especially on exotic machines.  If yours does, try the Bourne shell instead.)"
  39.  
  40. if test ! -d ../UU; then
  41.     if test ! -d UU; then
  42.     mkdir UU
  43.     fi
  44.     cd UU
  45. fi
  46.  
  47. case "$1" in
  48. -d) shift; fastread='yes';;
  49. esac
  50.  
  51. d_eunice=''
  52. d_xenix=''
  53. d_bsd=''
  54. define=''
  55. eunicefix=''
  56. loclist=''
  57. expr=''
  58. awk=''
  59. sed=''
  60. echo=''
  61. cat=''
  62. chgrp=''
  63. chmod=''
  64. chown=''
  65. rm=''
  66. mv=''
  67. cp=''
  68. tail=''
  69. tr=''
  70. mkdir=''
  71. sort=''
  72. uniq=''
  73. grep=''
  74. trylist=''
  75. test=''
  76. inews=''
  77. egrep=''
  78. more=''
  79. pg=''
  80. Mcc=''
  81. vi=''
  82. mail=''
  83. bison=''
  84. cpp=''
  85. perl=''
  86. Log=''
  87. Header=''
  88. Id=''
  89. bin=''
  90. contains=''
  91. cppstdin=''
  92. cppminus=''
  93. d_bzero=''
  94. d_cbrt=''
  95. d_index=''
  96. d_memset=''
  97. d_popen=''
  98. d_rusage=''
  99. d_times=''
  100. clocktype=''
  101. i_string=''
  102. strings=''
  103. i_sysresrc=''
  104. i_systypes=''
  105. i_time=''
  106. i_systime=''
  107. i_systimek=''
  108. timeincl=''
  109. inhdr=''
  110. inlibc=''
  111. libs=''
  112. models=''
  113. split=''
  114. small=''
  115. medium=''
  116. large=''
  117. huge=''
  118. ccflags=''
  119. ldflags=''
  120. cc=''
  121. cppflags=''
  122. optimize=''
  123. n=''
  124. c=''
  125. orderlib=''
  126. ranlib=''
  127. package=''
  128. randfunc=''
  129. mrand=''
  130. seedfunc=''
  131. nrandbits=''
  132. spitshell=''
  133. shsharp=''
  134. sharpbang=''
  135. startsh=''
  136. sysman=''
  137. voidflags=''
  138. defvoidused=''
  139. yacc=''
  140. d_urt=''
  141. urtinc=''
  142. urtlib=''
  143. i_stdlib=''
  144. libc=''
  145. mkdep=''
  146. CONFIG=''
  147. : set package name
  148. package=rayshade
  149.  
  150. echo " "
  151. echo "Beginning of configuration questions for $package kit."
  152. : Eunice requires " " instead of "", can you believe it
  153. echo " "
  154.  
  155. define='define'
  156. undef='undef'
  157. : change the next line if compiling for Xenix/286 on Xenix/386
  158. xlibpath='/usr/lib/386 /lib/386'
  159. libpth='/usr/lib /usr/local/lib /usr/lib/large /lib '$xlibpth' /lib/large'
  160. libpth=$libpth' /usr/lib/small /lib/small'
  161. smallmach='pdp11 i8086 z8000 i80286 iAPX286'
  162. rmlist='ark[1-9]isdone ark[1-9][0-9]isdone'
  163. trap 'echo " "; rm -f $rmlist; exit 1' 1 2 3 15
  164.  
  165. : We must find out about Eunice early
  166. eunicefix=':'
  167. if test -f /etc/unixtovms; then
  168.     eunicefix=/etc/unixtovms
  169. fi
  170. if test -f /etc/unixtovms.exe; then
  171.     eunicefix=/etc/unixtovms.exe
  172. fi
  173.  
  174. if ls blurfl >/dev/null 2>&1; then
  175.     if awk '' blurfl >/dev/null 2>&1; then
  176.         check='cat'
  177.     else
  178.         check='awk ""'
  179.     fi
  180. else
  181.     check='ls'
  182. fi
  183.  
  184. : Now test for existence of everything in MANIFEST
  185. if test -f ../MANIFEST; then
  186.     echo "First let's make sure your kit is complete.  Checking..."
  187.     : some grep do not return a proper exit status
  188.     grep '^---' ../MANIFEST > .grepmani 2>/dev/null
  189.     if test -s .grepmani; then
  190. (cd ..; eval $check `awk '!/^.*\/$/{if (b) print $1}
  191. /^---/{b=1}' MANIFEST` || kill $$) >/dev/null
  192.     else
  193. (cd ..; eval $check `awk '!/^.*\/$/{print $1}' MANIFEST` || kill $$) >/dev/null
  194.     fi
  195.     echo "Looks good..."
  196. else
  197.     echo "No MANIFEST found. Hope your kit is complete !"
  198. fi
  199. rm -f .grepmani
  200.  
  201. pth="/usr/ucb /bin /usr/bin /usr/local /usr/local/bin /usr/5bin"
  202. pth=$pth" /usr/lbin /etc /usr/new /usr/new/bin /usr/nbin /usr/gnu/bin"
  203. pth=$pth" /usr/plx /vol/local/bin /usr/lib /lib /usr/local/lib"
  204. pth=$pth" /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/bin"
  205. pth=$pth" /bsd4.3/usr/ucb /usr/bsd"
  206. : add PATH from user
  207. pth=$pth" "`echo $user_path | sed -e 's/:/ /g'`
  208. inclwanted=''
  209. defvoidused=15
  210. libswanted='m malloc c_s'
  211. defvoidused=11
  212. : some greps do not return status, grrr.
  213. echo "grimblepritz" >grimble
  214. if grep blurfldyick grimble >/dev/null 2>&1 ; then
  215.     contains=contains
  216. elif grep grimblepritz grimble >/dev/null 2>&1 ; then
  217.     contains=grep
  218. else
  219.     contains=contains
  220. fi
  221. rm -f grimble
  222. : the following should work in any shell
  223. case "$contains" in
  224. contains*)
  225.     echo " "
  226.     echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
  227.     cat >contains <<'EOSS'
  228. grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
  229. EOSS
  230. chmod +x contains
  231. esac
  232.  
  233. : see if sh knows # comments
  234. echo " "
  235. echo "Checking your sh to see if it knows about # comments..."
  236. if sh -c '#' >/dev/null 2>&1 ; then
  237.     echo "Your sh handles # comments correctly."
  238.     shsharp=true
  239.     spitshell=cat
  240.     echo " "
  241.     echo "Okay, let's see if #! works on this system..."
  242.     echo "#!/bin/echo hi" > try
  243.     $eunicefix try
  244.     chmod +x try
  245.     try > today
  246.     if $contains hi today >/dev/null 2>&1; then
  247.         echo "It does."
  248.         sharpbang='#!'
  249.     else
  250.         echo "#! /bin/echo hi" > try
  251.         $eunicefix try
  252.         chmod +x try
  253.         try > today
  254.         if test -s today; then
  255.             echo "It does."
  256.             sharpbang='#! '
  257.         else
  258.             echo "#!/bin/cat" > try
  259.             $eunicefix try
  260.             chmod +x try
  261.             try >today
  262.             if test -s today; then
  263.                 echo "It does, without processing parameters."
  264.                 sharpbang='#!'
  265.             else
  266.                 echo "It doesn't."
  267.                 sharpbang=': use '
  268.             fi
  269.         fi
  270.     fi
  271. else
  272.     echo "Your sh doesn't grok # comments--I will strip them later on."
  273.     shsharp=false
  274.     echo "exec grep -v '^[     ]*#'" >spitshell
  275.     chmod +x spitshell
  276.     $eunicefix spitshell
  277.     spitshell=`pwd`/spitshell
  278.     echo "I presume that if # doesn't work, #! won't work either!"
  279.     sharpbang=': use '
  280. fi
  281. rm -f try today
  282.  
  283. : figure out how to guarantee sh startup
  284. echo " "
  285. echo "Checking out how to guarantee sh startup..."
  286. startsh=$sharpbang'/bin/sh'
  287. echo "Let's see if '$startsh' works..."
  288. cat >try <<EOSS
  289. $startsh
  290. set abc
  291. test "$?abc" != 1
  292. EOSS
  293.  
  294. chmod +x try
  295. $eunicefix try
  296. if try; then
  297.     echo "Yup, it does."
  298. else
  299.     echo "Nope.  You may have to fix up the shell scripts to make sure sh runs them."
  300. fi
  301. rm -f try
  302.  
  303. : first determine how to suppress newline on echo command
  304. echo " "
  305. echo "Checking echo to see how to suppress newlines..."
  306. (echo "hi there\c" ; echo " ") >.echotmp
  307. if $contains c .echotmp >/dev/null 2>&1 ; then
  308.     echo "...using -n."
  309.     n='-n'
  310.     c=''
  311. else
  312.     cat <<'EOM'
  313. ...using \c
  314. EOM
  315.     n=''
  316.     c='\c'
  317. fi
  318. echo $n "The star should be here-->$c"
  319. echo '*'
  320. rm -f .echotmp
  321.  
  322. : now set up to do reads with possible shell escape and default assignment
  323. cat <<EOSC >myread
  324. case "\$fastread" in
  325. yes) ans=''; echo " " ;;
  326. *) ans='!';;
  327. esac
  328. while expr "X\$ans" : "X!" >/dev/null; do
  329.     read ans
  330.     case "\$ans" in
  331.     !)
  332.     sh
  333.     echo " "
  334.     echo $n "\$rp $c"
  335.     ;;
  336.     !*)
  337.     set \`expr "X\$ans" : "X!\(.*\)\$"\`
  338.     sh -c "\$*"
  339.     echo " "
  340.     echo $n "\$rp $c"
  341.     ;;
  342.     esac
  343. done
  344. rp='Your answer:'
  345. case "\$ans" in
  346. '') ans="\$dflt";;
  347. esac
  348. EOSC
  349.  
  350. : general instructions
  351. cat <<EOH
  352.  
  353. This installation shell script will examine your system and ask you questions
  354. to determine how the $package package should be installed.  If you get stuck
  355. on a question, you may use a ! shell escape to start a subshell or execute
  356. a command.  Many of the questions will have default answers in square
  357. brackets--typing carriage return will give you the default.
  358.  
  359. On some of the questions which ask for file or directory names you are
  360. allowed to use the ~name construct to specify the login directory belonging
  361. to "name", even if you don't have a shell which knows about that.  Questions
  362. where this is allowed will be marked "(~name ok)".
  363.  
  364. EOH
  365. rp="[Type carriage return to continue]"
  366. echo $n "$rp $c"
  367. . myread
  368. cat <<EOH
  369.  
  370. Much effort has been expended to ensure that this shell script will run on
  371. any Unix system. If despite that it blows up on you, your best bet is to edit
  372. Configure and run it again. Also, let me (rayshade-request@cs.princeton.edu)
  373. know how I blew it. If you can't run Configure for some reason, you'll have
  374. to generate a config.sh file by hand.
  375.  
  376. This installation script affects things in two ways:
  377. 1) it may do direct variable substitutions on some of the files included
  378.    in this kit.
  379. 2) it builds a config.h file for inclusion in C programs.  You may edit
  380.    any of these files as the need arises after running this script.
  381.  
  382. If you make a mistake on a question, there is no easy way to back up to it
  383. currently.  The easiest thing to do is to edit config.sh and rerun all the
  384. SH files.  Configure will offer to let you do this before it runs the SH files.
  385.  
  386. EOH
  387. rp="[Type carriage return to continue]"
  388. echo $n "$rp $c"
  389. . myread
  390.  
  391. : get old answers, if there is a config file out there
  392. if test -f ../config.sh; then
  393.     echo " "
  394.     dflt=y
  395.     rp="I see a config.sh file.  Did Configure make it on THIS system? [$dflt]"
  396.     echo $n "$rp $c"
  397.     . myread
  398.     case "$ans" in
  399.     n*|N*) echo "OK, I'll ignore it.";;
  400.     *)  echo "Fetching default answers from your old config.sh file..."
  401.     tmp="$n"
  402.     ans="$c"
  403.         . ../config.sh
  404.     n="$tmp"
  405.     c="$ans"
  406.     ;;
  407.     esac
  408. fi
  409.  
  410. : find out where common programs are
  411. echo " "
  412. echo "Locating common programs..."
  413. cat <<EOSC >loc
  414. $startsh
  415. case \$# in
  416. 0) exit 1;;
  417. esac
  418. thing=\$1
  419. shift
  420. dflt=\$1
  421. shift
  422. for dir in \$*; do
  423.     case "\$thing" in
  424.     .)
  425.     if test -d \$dir/\$thing; then
  426.         echo \$dir
  427.         exit 0
  428.     fi
  429.     ;;
  430.     *)
  431.     if test -f \$dir/\$thing; then
  432.         echo \$dir/\$thing
  433.         exit 0
  434.     elif test -f \$dir/\$thing.exe; then
  435.         : on Eunice apparently
  436.         echo \$dir/\$thing
  437.         exit 0
  438.     fi
  439.     ;;
  440.     esac
  441. done
  442. echo \$dflt
  443. exit 1
  444. EOSC
  445. chmod +x loc
  446. $eunicefix loc
  447. loclist="
  448. cat
  449. echo
  450. expr
  451. grep
  452. rm
  453. sed
  454. sort
  455. uniq
  456. "
  457. trylist="
  458. bison
  459. cpp
  460. test
  461. "
  462. for file in $loclist; do
  463.     xxx=`loc $file $file $pth`
  464.     eval $file=$xxx
  465.     eval _$file=$xxx
  466.     case "$xxx" in
  467.     /*)
  468.     echo $file is in $xxx.
  469.     ;;
  470.     *)
  471.     echo "I don't know where $file is.  I hope it's in everyone's PATH."
  472.     ;;
  473.     esac
  474. done
  475. echo " "
  476. echo "Don't worry if any of the following aren't found..."
  477. ans=offhand
  478. for file in $trylist; do
  479.     xxx=`loc $file $file $pth`
  480.     eval $file=$xxx
  481.     eval _$file=$xxx
  482.     case "$xxx" in
  483.     /*)
  484.     echo $file is in $xxx.
  485.     ;;
  486.     *)
  487.     echo "I don't see $file out there, $ans."
  488.     ans=either
  489.     ;;
  490.     esac
  491. done
  492. case "$egrep" in
  493. egrep)
  494.     echo "Substituting grep for egrep."
  495.     egrep=$grep
  496.     ;;
  497. esac
  498. case "$test" in
  499. test)
  500.     echo "Hopefully test is built into your sh."
  501.     ;;
  502. /bin/test)
  503.     if sh -c "PATH= test true" >/dev/null 2>&1; then
  504.     echo "Using the test built into your sh."
  505.     test=test
  506.     fi
  507.     ;;
  508. *)
  509.     test=test
  510.     ;;
  511. esac
  512. case "$echo" in
  513. echo)
  514.     echo "Hopefully echo is built into your sh."
  515.     ;;
  516. /bin/echo)
  517.     echo " "
  518.     echo "Checking compatibility between /bin/echo and builtin echo (if any)..."
  519.     $echo $n "hi there$c" >foo1
  520.     echo $n "hi there$c" >foo2
  521.     if cmp foo1 foo2 >/dev/null 2>&1; then
  522.     echo "They are compatible.  In fact, they may be identical."
  523.     else
  524.     case "$n" in
  525.     '-n') n='' c='\c' ans='\c' ;;
  526.     *) n='-n' c='' ans='-n' ;;
  527.     esac
  528.     cat <<FOO
  529. They are not compatible!  You are probably running ksh on a non-USG system.
  530. I'll have to use /bin/echo instead of the builtin, since Bourne shell doesn't
  531. have echo built in and we may have to run some Bourne shell scripts.  That
  532. means I'll have to use $ans to suppress newlines now.  Life is ridiculous.
  533.  
  534. FOO
  535.     rp="The star should be here-->"
  536.     $echo $n "$rp$c"
  537.     $echo "*"
  538.     fi
  539.     $rm -f foo1 foo2
  540.     ;;
  541. *)
  542.     : cross your fingers
  543.     echo=echo
  544.     ;;
  545. esac
  546. rmlist="$rmlist loc"
  547.  
  548. : Looking for optional libraries
  549. echo " "
  550. echo "Checking for optional libraries..."
  551. dflt=''
  552. case "$libswanted" in
  553. '') libswanted='c_s';;
  554. esac
  555. for thislib in $libswanted; do
  556.     case "$thislib" in
  557.     dbm) thatlib=ndbm;;
  558.     *_s) thatlib=NONE;;
  559.     *) thatlib="${thislib}_s";;
  560.     *) thatlib=NONE;;
  561.     esac
  562.     xxx=`loc lib$thislib.a X /usr/lib /usr/local/lib /lib`
  563.     if $test -f $xxx; then
  564.     echo "Found -l$thislib."
  565.     case "$dflt" in
  566.     *-l$thislib*|*-l$thatlib*);;
  567.     *) dflt="$dflt -l$thislib";;
  568.     esac
  569.     else
  570.     xxx=`loc lib$thislib.a X $libpth`
  571.     if $test -f $xxx; then
  572.         echo "Found $xxx."
  573.         case "$dflt" in
  574.         *$xxx*);;
  575.         *) dflt="$dflt $xxx";;
  576.         esac
  577.     else
  578.         xxx=`loc Slib$thislib.a X $xlibpth`
  579.         if $test -f $xxx; then
  580.         echo "Found -l$thislib."
  581.         case "$dflt" in
  582.         *-l$thislib*|*-l$thatlib*);;
  583.         *) dflt="$dflt -l$thislib";;
  584.         esac
  585.         else
  586.         echo "No -l$thislib."
  587.         fi
  588.     fi
  589.     fi
  590. done
  591. set X $dflt
  592. shift
  593. dflt="$*"
  594. case "$libs" in
  595. '') dflt="$dflt";;
  596. *) dflt="$libs";;
  597. esac
  598. case "$dflt" in
  599. '') dflt='none';;
  600. esac
  601.  
  602. $cat <<EOM
  603.  
  604. Some versions of Unix support shared libraries, which make
  605. executables smaller but make load time slightly longer.
  606.  
  607. On some systems, mostly newer Unix System V's, the shared library
  608. is included by putting the option "-lc_s" as the last thing on the
  609. cc command line when linking.  Other systems use shared libraries
  610. by default.  There may be other libraries needed to compile $package
  611. on your machine as well.  If your system needs the "-lc_s" option,
  612. include it here.  Include any other special libraries here as well.
  613. Say "none" for none.
  614. EOM
  615.  
  616. echo " "
  617. rp="Any additional libraries? [$dflt]"
  618. $echo $n "$rp $c"
  619. . myread
  620. case "$ans" in
  621. none) ans='';
  622. esac
  623. libs="$ans"
  624.  
  625. : get list of predefined functions in a handy place
  626. echo " "
  627. case "$libc" in
  628. '') libc=unknown;;
  629. esac
  630. case "$libpth" in
  631. '') libpth='/lib /usr/lib /usr/local/lib';;
  632. esac
  633. case "$libs" in
  634. *-lc_s*) libc=`loc libc_s.a $libc $libpth`
  635. esac
  636. libnames='';
  637. case "$libs" in
  638. '') ;;
  639. *)  for thislib in $libs; do
  640.     case "$thislib" in
  641.     -l*) thislib=`expr X$thislib : 'X-l\(.*\)'`
  642.         try=`loc lib$thislib.a blurfl/dyick $libpth`
  643.         if test ! -f $try; then
  644.         try=`loc lib$thislib blurfl/dyick $libpth`
  645.         if test ! -f $try; then
  646.             try=`loc $thislib blurfl/dyick $libpth`
  647.             if test ! -f $try; then
  648.             try=`loc Slib$thislib.a blurfl/dyick $xlibpth`
  649.             if test ! -f $try; then
  650.                 try=''
  651.             fi
  652.             fi
  653.         fi
  654.         fi
  655.         libnames="$libnames $try"
  656.         ;;
  657.     *) libnames="$libnames $thislib" ;;
  658.     esac
  659.     done
  660.     ;;
  661. esac
  662. set /usr/ccs/lib/libc.so
  663. test -f $1 || set /usr/lib/libc.so
  664. test -f $1 || set /usr/lib/libc.so.[0-9]*
  665. eval set \$$#
  666. if test -f "$1"; then
  667.     echo "Your shared C library is in $1."
  668.     libc="$1"
  669. elif test -f /lib/libc && test -f /lib/clib; then
  670.     echo "Your C library is in both /lib/clib and /lib/libc."
  671.     libc='/lib/clib /lib/libc'
  672.     if test -f /lib/syslib; then
  673.         echo "(Your math library is in /lib/syslib.)"
  674.         libc="$libc /lib/syslib"
  675.     fi
  676. elif test -f $libc; then
  677.     echo "Your C library is in $libc, like you said before."
  678. elif test -f /lib/libc.a; then
  679.     echo "Your C library is in /lib/libc.a.  You're normal."
  680.     libc=/lib/libc.a
  681. else
  682.     ans=`loc libc.a blurfl/dyick $libpth`
  683.     if test ! -f "$ans"; then
  684.     ans=`loc Slibc.a blurfl/dyick $xlibpth`
  685.     fi
  686.     if test ! -f "$ans"; then
  687.     ans=`loc Mlibc.a blurfl/dyick $xlibpth`
  688.     fi
  689.     if test ! -f "$ans"; then
  690.     ans=`loc Llibc.a blurfl/dyick $xlibpth`
  691.     fi
  692.     if test ! -f "$ans"; then
  693.     ans=`loc libc blurfl/dyick $libpth`
  694.     fi
  695.     if test ! -f "$ans"; then
  696.     ans=`loc clib blurfl/dyick $libpth`
  697.     fi
  698.     if test ! -f "$ans"; then
  699.          ans=`loc libsys_s.a blurfl/dyick $libpth`
  700.     fi
  701.     if test -f "$ans"; then
  702.     echo "Your C library is in $ans, of all places."
  703.     libc=$ans
  704.     else
  705.     cat <<EOM
  706.  
  707. I can't seem to find your C library.  I've looked in the following places:
  708.  
  709.     $libpth
  710.  
  711. None of these seems to contain your C library.  What is the full name
  712. EOM
  713.     dflt=None
  714.     $echo $n "of your C library? $c"
  715.     rp='C library full name?'
  716.     . myread
  717.     libc="$ans"
  718.     fi
  719. fi
  720. echo " "
  721. set `echo $libc $libnames | tr ' ' '\012' | sort | uniq`
  722. $echo $n "Extracting names from $* for later perusal...$c"
  723. nm $* 2>/dev/null >libc.tmp
  724. $grep printf libc.tmp > libc.ptf
  725. com="$sed -n -e 's/^.* [ADTS]  *_[_.]*//p' -e 's/^.* [ADTS] //p'"
  726. eval "$com <libc.ptf >libc.list"
  727. if $contains '^printf$' libc.list >/dev/null 2>&1; then
  728.     :
  729. else
  730.     com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'"
  731.     eval "$com <libc.ptf >libc.list"
  732. fi
  733. if $contains '^printf$' libc.list >/dev/null 2>&1; then
  734.     :
  735. else
  736.     com="$sed -n -e '/|Undef/d' -e '/|Proc/s/ .*//p'"
  737.     eval "$com <libc.ptf >libc.list"
  738. fi
  739. if $contains '^printf$' libc.list >/dev/null 2>&1; then
  740.     :
  741. else
  742.     com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'"
  743.     eval "$com <libc.ptf >libc.list"
  744. fi
  745. if $contains '^printf$' libc.list >/dev/null 2>&1; then
  746.     :
  747. else
  748.     com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'"
  749.     eval "$com <libc.ptf >libc.list"
  750. fi
  751. if $contains '^printf$' libc.list >/dev/null 2>&1; then
  752.     :
  753. else
  754.     com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'"
  755.     eval "$com <libc.ptf >libc.list"
  756. fi
  757. if $contains '^printf$' libc.list >/dev/null 2>&1; then
  758.     :
  759. else
  760.     com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'"
  761.     eval "$com <libc.ptf >libc.list"
  762. fi
  763. if $contains '^printf$' libc.list >/dev/null 2>&1; then
  764.     eval "$com <libc.tmp >libc.list"
  765.     echo "done"
  766. else
  767.     echo " "
  768.     echo "nm didn't seem to work right."
  769.     echo "Trying ar instead..."
  770.     if ar t $libc > libc.tmp; then
  771.         for thisname in $libnames; do
  772.             ar t $thisname >>libc.tmp
  773.         done
  774.         $sed -e 's/\.o$//' < libc.tmp > libc.list
  775.         echo "Ok."
  776.     else
  777.         echo "ar didn't seem to work right."
  778.         echo "Maybe this is a Cray...trying bld instead..."
  779.         if bld t $libc | $sed -e 's/.*\///' -e 's/\.o:.*$//' > libc.list; then
  780.             for thisname in $libnames; do
  781.                 bld t $libnames | \
  782.                 $sed -e 's/.*\///' -e 's/\.o:.*$//' >>libc.list
  783.                 ar t $thisname >>libc.tmp
  784.             done
  785.             echo "Ok."
  786.         else
  787.             echo "That didn't work either.  Giving up."
  788.             exit 1
  789.         fi
  790.     fi
  791. fi
  792.  
  793. : define an in-header-list? function
  794. inhdr='echo " ";
  795. xxx=`loc $1 x /usr/include /usr/local/include $inclwanted`;
  796. if $test -f $xxx;
  797. then echo "<$1> found."; eval "$2=$define";
  798. else echo "No <$1> found."; eval "$2=$undef"; fi'
  799.  
  800. : see if sys/types.h has to be included
  801. set sys/types.h i_systypes
  802. eval $inhdr
  803.  
  804. : see if times exists
  805. echo " "
  806. if $contains '^times$' libc.list >/dev/null 2>&1; then
  807.     echo 'times() found.'
  808.     d_times="$define"
  809.     case "$clocktype" in
  810.     '')
  811.         if $contains 'clock_t;' /usr/include/sys/types.h >/dev/null 2>&1 ; then
  812.             dflt='clock_t';
  813.         elif $contains 'clock_t;' /usr/include/sys/times.h >/dev/null 2>&1; then
  814.             dflt='clock_t';
  815.         else
  816.             dflt='long';
  817.         fi
  818.         ;;
  819.     *)  dflt="$clocktype"
  820.         ;;
  821.     esac
  822.     cont=true
  823.     echo " "
  824.     rp="What type is returned by times() on this sytem? [$dflt]"
  825.     $echo $n "$rp $c"
  826.     . myread
  827.     clocktype="$ans"
  828. else
  829.     echo 'times() not found, hope that will do.'
  830.     d_times="$undef"
  831.     clocktype='int'
  832. fi
  833.  
  834. : set up shell script to do ~ expansion
  835. cat >filexp <<EOSS
  836. $startsh
  837. : expand filename
  838. case "\$1" in
  839.  ~/*|~)
  840.     echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
  841.     ;;
  842.  ~*)
  843.     if $test -f /bin/csh; then
  844.     /bin/csh -f -c "glob \$1"
  845.     echo ""
  846.     else
  847.     name=\`$expr x\$1 : '..\([^/]*\)'\`
  848.     dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
  849.     if $test ! -d "\$dir"; then
  850.         me=\`basename \$0\`
  851.         echo "\$me: can't locate home directory for: \$name" >&2
  852.         exit 1
  853.     fi
  854.     case "\$1" in
  855.     */*)
  856.         echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
  857.         ;;
  858.     *)
  859.         echo \$dir
  860.         ;;
  861.     esac
  862.     fi
  863.     ;;
  864. *)
  865.     echo \$1
  866.     ;;
  867. esac
  868. EOSS
  869. chmod +x filexp
  870. $eunicefix filexp
  871.  
  872. : determine where manual pages are on this system
  873. echo " "
  874. case "$sysman" in
  875.     '') sysman=`loc . /usr/man/man1 /usr/man/man1 /usr/man/mann /usr/man/manl /usr/man/local/man1 /usr/man/u_man/man1 /usr/share/man/man1 /usr/catman/u_man/man1 /usr/man/l_man/man1 /usr/local/man/u_man/man1 /usr/local/man/l_man/man1 /usr/man/man.L`
  876.     ;;
  877. esac
  878. if test -d "$sysman"; then
  879.     echo "System manual is in $sysman."
  880. fi
  881.  
  882. : make some quick guesses about what we are up against
  883. echo " "
  884. $echo $n "Hmm...  $c"
  885. cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null
  886. if test `echo abc | tr a-z A-Z` = Abc ; then
  887.     if $contains SIGTSTP foo >/dev/null 2>&1 ; then
  888.     echo "Looks kind of like an USG system with BSD features, but we'll see..."
  889.         echo exit 0 >bsd
  890.         echo exit 0 >usg
  891.         echo exit 1 >v7
  892.     else
  893.     echo "Looks kind of like an USG system, but we'll see..."
  894.         echo exit 1 >bsd
  895.         echo exit 0 >usg
  896.         echo exit 1 >v7
  897.     fi
  898.     d_bsd="$undef"
  899. elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
  900.     echo "Looks kind of like a BSD system, but we'll see..."
  901.     d_bsd="$define"
  902.     echo exit 0 >bsd
  903.     echo exit 1 >usg
  904.     echo exit 1 >v7
  905. else
  906.     echo "Looks kind of like a Version 7 system, but we'll see..."
  907.     d_bsd="$undef"
  908.     echo exit 1 >bsd
  909.     echo exit 1 >usg
  910.     echo exit 0 >v7
  911. fi
  912. case "$eunicefix" in
  913. *unixtovms*)
  914.     cat <<'EOI'
  915. There is, however, a strange, musty smell in the air that reminds me of
  916. something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
  917. EOI
  918.     echo "exit 0" >eunice
  919.     eunicefix=unixtovms
  920.     d_eunice="$define"
  921. : it so happens the Eunice I know will not run shell scripts in Unix format
  922.     ;;
  923. *)
  924.     echo " "
  925.     echo "Congratulations.  You aren't running Eunice."
  926.     eunicefix=':'
  927.     d_eunice="$undef"
  928.     echo "exit 1" >eunice
  929.     ;;
  930. esac
  931. if test -f /xenix; then
  932.     echo "Actually, this looks more like a XENIX system..."
  933.     echo "exit 0" >xenix
  934.     d_xenix="$define"
  935. else
  936.     echo " "
  937.     echo "It's not Xenix..."
  938.     echo "exit 1" >xenix
  939.     d_xenix="$undef"
  940. fi
  941. chmod +x xenix
  942. $eunicefix xenix
  943. if test -f /venix; then
  944.     echo "Actually, this looks more like a VENIX system..."
  945.     echo "exit 0" >venix
  946. else
  947.     echo " "
  948.     if xenix; then
  949.     : null
  950.     else
  951.     echo "Nor is it Venix..."
  952.     fi
  953.     echo "exit 1" >venix
  954. fi
  955. chmod +x bsd usg v7 eunice venix
  956. $eunicefix bsd usg v7 eunice venix
  957. rm -f foo
  958. rmlist="$rmlist bsd usg v7 eunice venix xenix"
  959.  
  960. : see what memory models we can support
  961. case "$models" in
  962. '')
  963.     cat >pdp11.c <<'EOP'
  964. main() {
  965. #ifdef pdp11
  966.     exit(0);
  967. #else
  968.     exit(1);
  969. #endif
  970. }
  971. EOP
  972.     cc -o pdp11 pdp11.c >/dev/null 2>&1
  973.     if pdp11 2>/dev/null; then
  974.         dflt='unsplit split'
  975.     else
  976.         ans=`loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge`
  977.         case "$ans" in
  978.         X) dflt='none';;
  979.         *) if $test -d /lib/small || $test -d /usr/lib/small; then
  980.                 dflt='small'
  981.             else
  982.                 dflt=''
  983.             fi
  984.             if $test -d /lib/medium || $test -d /usr/lib/medium; then
  985.                 dflt="$dflt medium"
  986.             fi
  987.             if $test -d /lib/large || $test -d /usr/lib/large; then
  988.                 dflt="$dflt large"
  989.             fi
  990.             if $test -d /lib/huge || $test -d /usr/lib/huge; then
  991.                 dflt="$dflt huge"
  992.             fi
  993.         esac
  994.     fi;;
  995. *) dflt="$models";;
  996. esac
  997. $cat <<EOM
  998.  
  999. Some systems have different model sizes.  On most systems they are called
  1000. small, medium, large, and huge.  On the PDP11 they are called unsplit and
  1001. split.  If your system doesn't support different memory models, say "none".
  1002. If you wish to force everything to one memory model, say "none" here and
  1003. put the appropriate flags later when it asks you for other cc and ld flags.
  1004. Venix systems may wish to put "none" and let the compiler figure things out.
  1005. (In the following question multiple model names should be space separated.)
  1006.  
  1007. EOM
  1008. rp="Which models are supported? [$dflt]"
  1009. $echo $n "$rp $c"
  1010. . myread
  1011. models="$ans"
  1012.  
  1013. case "$models" in
  1014. none)
  1015.     small=''
  1016.     medium=''
  1017.     large=''
  1018.     huge=''
  1019.     unsplit=''
  1020.     split=''
  1021.     ;;
  1022. *split)
  1023.     case "$split" in
  1024.     '') if $contains '\-i' $mansrc/ld.1 >/dev/null 2>&1 || \
  1025.              $contains '\-i' $mansrc/cc.1 >/dev/null 2>&1; then
  1026.             dflt='-i'
  1027.         else
  1028.             dflt='none'
  1029.         fi;;
  1030.     *) dflt="$split";;
  1031.     esac
  1032.     rp="What flag indicates separate I and D space? [$dflt]"
  1033.     $echo $n "$rp $c"
  1034.     . myread
  1035.     case "$ans" in
  1036.     none) ans='';;
  1037.     esac
  1038.     split="$ans"
  1039.     unsplit='';;
  1040. *large*|*small*|*medium*|*huge*)
  1041.     case "$model" in
  1042.     *large*)
  1043.         case "$large" in
  1044.         '') dflt='-Ml';;
  1045.         *) dflt="$large";;
  1046.         esac
  1047.     rp="What flag indicates large model? [$dflt]"
  1048.     $echo $n "$rp $c"
  1049.     . myread
  1050.     case "$ans" in
  1051.     none) ans='';
  1052.     esac
  1053.     large="$ans";;
  1054.     *) large='';;
  1055.     esac
  1056.     case "$model" in
  1057.     *huge*) case "$huge" in
  1058.         '') dflt='-Mh';;
  1059.         *) dflt="$huge";;
  1060.         esac
  1061.         rp="What flag indicates huge model? [$dflt]"
  1062.         $echo $n "$rp $c"
  1063.         . myread
  1064.         case "$ans" in
  1065.         none) ans='';
  1066.         esac
  1067.         huge="$ans";;
  1068.     *) huge="$large";;
  1069.     esac
  1070.     case "$model" in
  1071.     *medium*) case "$medium" in
  1072.         '') dflt='-Mm';;
  1073.         *) dflt="$medium";;
  1074.         esac
  1075.         rp="What flag indicates medium model? [$dflt]"
  1076.         $echo $n "$rp $c"
  1077.         . myread
  1078.         case "$ans" in
  1079.         none) ans='';
  1080.         esac
  1081.         medium="$ans";;
  1082.     *) medium="$large";;
  1083.     esac
  1084.     case "$model" in
  1085.     *small*) case "$small" in
  1086.         '') dflt='none';;
  1087.         *) dflt="$small";;
  1088.         esac
  1089.         rp="What flag indicates small model? [$dflt]"
  1090.         $echo $n "$rp $c"
  1091.         . myread
  1092.         case "$ans" in
  1093.         none) ans='';
  1094.         esac
  1095.         small="$ans";;
  1096.     *) small='';;
  1097.     esac
  1098.     ;;
  1099. *)
  1100.     echo "Unrecognized memory models--you may have to edit Makefile.SH"
  1101.     ;;
  1102. esac
  1103.  
  1104. : see if we need a special compiler
  1105. echo " "
  1106. if usg; then
  1107.     case "$cc" in
  1108.     '')
  1109.     case "$Mcc" in
  1110.     /*) dflt='Mcc'
  1111.         ;;
  1112.     *)
  1113.         case "$large" in
  1114.         -M*)
  1115.         dflt='cc'
  1116.         ;;
  1117.         *)
  1118.         if $contains '\-M' $mansrc/cc.1 >/dev/null 2>&1 ; then
  1119.             dflt='cc -M'
  1120.         else
  1121.             dflt='cc'
  1122.         fi
  1123.         ;;
  1124.         esac
  1125.         ;;
  1126.     esac
  1127.     ;;
  1128.     *)  dflt="$cc";;
  1129.     esac
  1130.     $cat <<'EOM'
  1131.  
  1132. On some systems the default C compiler will not resolve multiple global
  1133. references that happen to have the same name.  On some such systems the
  1134. "Mcc" command may be used to force these to be resolved.  On other systems
  1135. a "cc -M" command is required.  (Note that the -M flag on other systems
  1136. indicates a memory model to use!)  If you have the Gnu C compiler, you
  1137. might wish to use that instead.  What command will force resolution on
  1138. EOM
  1139.     $echo $n "this system? [$dflt] $c"
  1140.     rp="Command to resolve multiple refs? [$dflt]"
  1141.     . myread
  1142.     cc="$ans"
  1143. else
  1144.     case "$cc" in
  1145.     '') dflt=cc;;
  1146.     *) dflt="$cc";;
  1147.     esac
  1148.     rp="Use which C compiler? [$dflt]"
  1149.     $echo $n "$rp $c"
  1150.     . myread
  1151.     cc="$ans"
  1152. fi
  1153. case "$cc" in
  1154. gcc*) cpp=`loc gcc-cpp $cpp $pth`;;
  1155. esac
  1156.  
  1157. : determine optimize, if desired, or use for debug flag also
  1158. case "$optimize" in
  1159. ' ') dflt="none";;
  1160. '') dflt="-O";;
  1161. *) dflt="$optimize";;
  1162. esac
  1163. cat <<EOH
  1164.  
  1165. Some C compilers have problems with their optimizers, by default, $package
  1166. compiles with the -O flag to use the optimizer.  Alternately, you might
  1167. want to use the symbolic debugger, which uses the -g flag (on traditional
  1168. Unix systems).  Either flag can be specified here.  To use neither flag,
  1169. specify the word "none".
  1170.   
  1171. EOH
  1172. rp="What optimizer/debugger flag should be used? [$dflt]"
  1173. $echo $n "$rp $c"
  1174. . myread
  1175. optimize="$ans"
  1176. case "$optimize" in
  1177. 'none') optimize=" ";;
  1178. esac
  1179.  
  1180. case "$ccflags" in
  1181. '') case "$cc" in
  1182.     *gcc*) dflt='-fpcc-struct-return';;
  1183.     *) dflt='';;
  1184.     esac
  1185.     ;;
  1186. *) dflt="$ccflags";;
  1187. esac
  1188. for thisincl in $inclwanted; do
  1189.     if $test -d $thisincl; then
  1190.         case "$dflt" in
  1191.         *$thisincl*);;
  1192.         *) dflt="$dflt -I$thisincl";;
  1193.         esac
  1194.     fi
  1195. done
  1196. case "$optimize" in
  1197. -g*)
  1198.     case "$dflt" in
  1199.     *DEBUG*);;
  1200.     *) dflt="$dflt -DDEBUG";;
  1201.     esac
  1202.     ;;
  1203. esac
  1204. if $contains 'LANGUAGE_C' /usr/include/signal.h >/dev/null 2>&1; then
  1205.     case "$dflt" in
  1206.     *LANGUAGE_C*);;
  1207.     *) dflt="$dflt -DLANGUAGE_C";;
  1208.     esac
  1209. fi
  1210. case "$dflt" in
  1211. '') dflt=none;;
  1212. esac
  1213. cat <<EOH
  1214.  
  1215. Your C compiler may want other flags.  For this question you should
  1216. include -I/whatever and -DWHATEVER flags and any other flags used by
  1217. the C compiler, but you should NOT include libraries or ld flags like
  1218. -lwhatever.  To use no flags, specify the word "none".
  1219.   
  1220. EOH
  1221. rp="Any additional cc flags? [$dflt]"
  1222. $echo $n "$rp $c"
  1223. . myread
  1224. case "$ans" in
  1225. none) ans='';
  1226. esac
  1227. ccflags="$ans"
  1228.  
  1229. : the following weeds options from ccflags that are of no interest to cpp
  1230. cppflags="$ccflags"
  1231. case "$cc" in
  1232. *gcc*) cppflags="$cppflags -D__GNUC__";;
  1233. esac
  1234. case "$cppflags" in
  1235. '');;
  1236. *)  set X $cppflags
  1237.     cppflags=''
  1238.     for flag do
  1239.         case $flag in
  1240.         -D*|-I*) cppflags="$cppflags $flag";;
  1241.         esac
  1242.     done
  1243.     case "$cppflags" in
  1244.     *-*)  echo "(C preprocessor flags: $cppflags)";;
  1245.     esac
  1246.     ;;
  1247. esac
  1248.  
  1249. case "$ldflags" in
  1250. '') if venix; then
  1251.         dflt='-i -z'
  1252.     else
  1253.         dflt='none'
  1254.     fi
  1255.     ;;
  1256. *) dflt="$ldflags";;
  1257. esac
  1258. echo " "
  1259. rp="Any additional ld flags (NOT including libraries)? [$dflt]"
  1260. $echo $n "$rp $c"
  1261. . myread
  1262. case "$ans" in
  1263. none) ans='';
  1264. esac
  1265. ldflags="$ans"
  1266. rmlist="$rmlist pdp11"
  1267.  
  1268. : see how we invoke the C preprocessor
  1269. echo " "
  1270. echo "Now, how can we feed standard input to your C preprocessor..."
  1271. cat <<'EOT' >testcpp.c
  1272. #define ABC abc
  1273. #define XYZ xyz
  1274. ABC.XYZ
  1275. EOT
  1276. echo 'Maybe "'"$cc"' -E" will work...'
  1277. $cc -E <testcpp.c >testcpp.out 2>&1
  1278. if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1279.     echo "Yup, it does."
  1280.     cppstdin="$cc -E"
  1281.     cppminus='';
  1282. else
  1283.     echo 'Nope, maybe "'$cpp'" will work...'
  1284.     $cpp <testcpp.c >testcpp.out 2>&1
  1285.     if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1286.     echo "Yup, it does."
  1287.     cppstdin="$cpp"
  1288.     cppminus='';
  1289.     else
  1290.     echo 'No such luck...maybe "'$cpp' -" will work...'
  1291.     $cpp - <testcpp.c >testcpp.out 2>&1
  1292.     if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1293.         echo "It works!"
  1294.         cppstdin="$cpp"
  1295.         cppminus='-';
  1296.     else
  1297.         echo 'Nixed again...maybe "'"$cc"' -E -" will work...'
  1298.         $cc -E - <testcpp.c >testcpp.out 2>&1
  1299.         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1300.         echo "Hooray, it works!  I was beginning to wonder."
  1301.         cppstdin="$cc -E"
  1302.         cppminus='-';
  1303.         else
  1304.         echo 'Nope...maybe "'"$cc"' -P" will work...'
  1305.         $cc -P <testcpp.c >testcpp.out 2>&1
  1306.         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1307.             echo "Yup, that does."
  1308.             cppstdin="$cc -P"
  1309.             cppminus='';
  1310.         else
  1311.             echo 'Nope...maybe "'"$cc"' -P -" will work...'
  1312.             $cc -P - <testcpp.c >testcpp.out 2>&1
  1313.             if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1314.             echo "Yup, that does."
  1315.             cppstdin="$cc -P"
  1316.             cppminus='-';
  1317.             else
  1318.             echo 'Hmm...perhaps you already told me...'
  1319.             case "$cppstdin" in
  1320.             '') ;;
  1321.             *) $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1;;
  1322.             esac
  1323.             if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1324.                 echo "Hooray, you did!  I was beginning to wonder."
  1325.             else
  1326.                 echo 'Uh-uh.  Time to get fancy...'
  1327.                 cd ..
  1328.                 echo 'Trying (cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c)'
  1329.                 echo 'cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c' >cppstdin
  1330.                 chmod 755 cppstdin
  1331.                 cppstdin=`pwd`/cppstdin
  1332.                 cppminus='';
  1333.                 cd UU
  1334.                 $cppstdin <testcpp.c >testcpp.out 2>&1
  1335.                 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1336.                 echo "Eureka!."
  1337.                 else
  1338.                 dflt=blurfl
  1339.                 $echo $n "No dice.  I can't find a C preprocessor.  Name one: $c"
  1340.                 rp='Name a C preprocessor:'
  1341.                 . myread
  1342.                 cppstdin="$ans"
  1343.                 $cppstdin <testcpp.c >testcpp.out 2>&1
  1344.                 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1345.                     echo "OK, that will do."
  1346.                 else
  1347.                     echo "Sorry, I can't get that to work.  Go find one."
  1348.                     exit 1
  1349.                 fi
  1350.                 fi
  1351.             fi
  1352.             fi
  1353.         fi
  1354.         fi
  1355.     fi
  1356.     fi
  1357. fi
  1358. rm -f testcpp.c testcpp.out
  1359.  
  1360. : define an is-in-libc? function and set rmlist
  1361. inlibc='echo " ";
  1362. if $contains "^$1\$" libc.list >/dev/null 2>&1;
  1363. then echo "$1() found."; eval "$2=$define";
  1364. else echo "$1() not found."; eval "$2=$undef"; fi'
  1365.  
  1366. rmlist="$rmlist libc.tmp libc.list"
  1367.  
  1368. : see if memset exists
  1369. set memset d_memset
  1370. eval $inlibc
  1371.  
  1372. : see if bzero exists
  1373. echo " "
  1374. if $contains '^bzero$' libc.list >/dev/null 2>&1; then
  1375.     echo 'bzero() found.'
  1376.     d_bzero="$undef"
  1377. elif $test $d_memset = "$define" ; then
  1378.     echo "bzero() not found -- Will use memset() instead."
  1379.     d_bzero="$define"
  1380. else
  1381.     echo "bzero() not found."
  1382.     d_bzero="$define"
  1383. fi
  1384.  
  1385. : see if cbrt exists
  1386. set cbrt d_cbrt
  1387. eval $inlibc
  1388.  
  1389. : see which of string.h or strings.h is needed
  1390. echo " "
  1391. strings=`loc string.h "" /usr/include $inclwanted`
  1392. i_string="$undef"
  1393. if $test -r "$strings"; then
  1394.     echo "Using <string.h> instead of <strings.h>."
  1395.     if bsd; then
  1396.         echo "(Actually, this looks more like it were an USG system)"
  1397.     fi
  1398.     i_string="$define"
  1399. else
  1400.     strings=`loc strings.h "" /usr/include $inclwanted`
  1401.     if $test -r "$strings"; then
  1402.         echo "Using <strings.h> instead of <string.h>."
  1403.         if usg; then
  1404.             echo "(Actually, this looks more like it were a BSD system)"
  1405.         fi
  1406.     else
  1407.         echo "No string header found--You'll surely have problems."
  1408.     fi
  1409. fi
  1410.  
  1411. : index or strchr
  1412. echo " "
  1413. case "$d_index" in
  1414. n) dflt=n;;
  1415. *) dflt=y;;
  1416. esac
  1417. if $contains '^index$' libc.list >/dev/null 2>&1 ; then
  1418.     if $contains '^strchr$' libc.list >/dev/null 2>&1 ; then
  1419.         if $contains strchr "$strings" >/dev/null 2>&1 ; then
  1420.             if $contains index "$strings" >/dev/null 2>&1 ; then
  1421.                 echo "Your system has both index() and strchr().  Shall I use"
  1422.                 rp="index() rather than strchr()? [$dflt]"
  1423.                 $echo $n "$rp $c"
  1424.                 . myread
  1425.                 case "$ans" in
  1426.                     n*) d_index="$define" ;;
  1427.                     *)  d_index="$undef" ;;
  1428.                 esac
  1429.             else
  1430.                 d_index="$define"
  1431.                 echo "strchr() found."
  1432.             fi
  1433.         else
  1434.             d_index="$undef"
  1435.             echo "index() found."
  1436.         fi
  1437.     else
  1438.         d_index="$undef"
  1439.         echo "index() found."
  1440.     fi
  1441. else
  1442.     if $contains '^strchr$' libc.list >/dev/null 2>&1 ; then
  1443.         d_index="$define"
  1444.         echo "strchr() found."
  1445.     else
  1446.         echo "No index() or strchr() found!"
  1447.         d_index="$undef"
  1448.     fi
  1449. fi
  1450.  
  1451. : see if popen exists
  1452. set popen d_popen
  1453. eval $inlibc
  1454.  
  1455. : see if sys/resource.h has to be included
  1456. set sys/resource.h i_sysresrc
  1457. eval $inhdr
  1458.  
  1459. : see if we should include time.h, sys/time.h, or both
  1460. cat <<'EOM'
  1461.   
  1462. Testing to see if we should include <time.h>, <sys/time.h> or both.
  1463. I'm now running the test program...
  1464. EOM
  1465. $cat >try.c <<'EOCP'
  1466. #include <sys/types.h>
  1467. #ifdef I_TIME
  1468. #include <time.h>
  1469. #endif
  1470. #ifdef I_SYSTIME
  1471. #ifdef SYSTIMEKERNEL
  1472. #define KERNEL
  1473. #endif
  1474. #include <sys/time.h>
  1475. #endif
  1476. main()
  1477. {
  1478.     struct tm foo;
  1479. #ifdef S_TIMEVAL
  1480.     struct timeval bar;
  1481. #endif
  1482.     if (foo.tm_sec == foo.tm_sec)
  1483.     exit(0);
  1484. #ifdef S_TIMEVAL
  1485.     if (bar.tv_sec == bar.tv_sec)
  1486.     exit(0);
  1487. #endif
  1488.     exit(1);
  1489. }
  1490. EOCP
  1491. flags=''
  1492. for s_timeval in '-DS_TIMEVAL' ''; do
  1493.     for i_systimek in '' '-DSYSTIMEKERNEL'; do
  1494.     for i_time in '' '-DI_TIME'; do
  1495.         for i_systime in '-DI_SYSTIME' ''; do
  1496.         case "$flags" in
  1497.         '') echo Trying $i_time $i_systime $i_systimek $s_timeval
  1498.             if $cc $ccflags \
  1499.                 $i_time $i_systime $i_systimek $s_timeval \
  1500.                 try.c -o try >/dev/null 2>&1 ; then
  1501.             set X $i_time $i_systime $i_systimek $s_timeval
  1502.             shift
  1503.             flags="$*"
  1504.             echo Succeeded with $flags
  1505.             fi
  1506.             ;;
  1507.         esac
  1508.         done
  1509.     done
  1510.     done
  1511. done
  1512. timeincl=''
  1513. case "$flags" in
  1514. *SYSTIMEKERNEL*) i_systimek="$define"
  1515.     timeincl='/usr/include/sys/time.h'
  1516.     echo "We'll include <sys/time.h> with KERNEL defined.";;
  1517. *) i_systimek="$undef";;
  1518. esac
  1519. case "$flags" in
  1520. *I_TIME*) i_time="$define"
  1521.     timeincl='/usr/include/time.h'
  1522.     echo "We'll include <time.h>.";;
  1523. *) i_time="$undef";;
  1524. esac
  1525. case "$flags" in
  1526. *I_SYSTIME*) i_systime="$define"
  1527.     timeincl='/usr/include/sys/time.h'
  1528.     echo "We'll include <sys/time.h>.";;
  1529. *) i_systime="$undef";;
  1530. esac
  1531. $rm -f try.c try
  1532.  
  1533. : see if getrusage exists
  1534. echo " "
  1535. if $contains getrusage libc.list >/dev/null 2>&1; then
  1536.     echo 'getrusage() found.'
  1537.     d_rusage="$define"
  1538. else
  1539.     echo 'getrusage() not found--cpu accounting may be less accurate.'
  1540.     d_rusage="$undef"
  1541. fi
  1542.  
  1543.  
  1544. : determine if we want to use the URT
  1545. case "$urtinc" in
  1546. '')
  1547.     dflt='none'
  1548.     ;;
  1549. *)  dflt=`echo $urtinc | $sed -e 's/-I//'`
  1550.     ;;
  1551. esac
  1552.  
  1553. echo " "
  1554. echo "$package works best when linked with the Utah Raster Toolkit."
  1555. echo "If you don't have the URT, $package will compile, but with many"
  1556.  
  1557. $cat << EOT
  1558. useful features disabled.
  1559.  
  1560. In addition to providing a library for reading and writing compact
  1561. image files, the URT offers a host of useful image-maniuplation tools.
  1562. You are strongly encouraged to get a copy.
  1563.  
  1564. If you do not have a copy of the URT, answer 'none' below.
  1565.  
  1566. EOT
  1567.  
  1568. rp="What directory holds the Utah Raster Toolkit include files? [$dflt]"
  1569. $echo $n "$rp $c"
  1570. . myread
  1571. case "$ans" in
  1572. 'none')
  1573.     urtinc=''
  1574.     urtlib=''
  1575.     d_urt="$undef"
  1576.     ;;
  1577. *)
  1578.     urtinc="$ans"
  1579.     d_urt="$define"
  1580.     case "$urtlib" in
  1581.     '')
  1582.         dflt=`$echo $urtinc | $sed -e 's/include/lib\/librle.a/g'`
  1583.         if test ! -f "$dflt"; then
  1584.             dflt="/usr/local/lib/librle.a"
  1585.         fi
  1586.         ;;
  1587.     *)
  1588.         dflt="$urtlib"
  1589.         ;;
  1590.     esac
  1591.     echo " "
  1592.     rp="Where is the Utah Raster Toolkit library? [$dflt]"
  1593.     $echo $n "$rp $c"
  1594.     . myread
  1595.     urtlib="$ans"
  1596.     urtinc="-I$urtinc"
  1597.     ;;
  1598. esac
  1599. : see if this is a stdlib.h
  1600. echo " "
  1601. if $test -r /usr/include/stdlib.h ; then
  1602.     i_stdlib="$define"
  1603.     echo "<stdlib.h> found."
  1604. else
  1605.     i_stdlib="$undef"
  1606. fi
  1607.  
  1608. : How can we generate normalized random numbers ?
  1609. echo " "
  1610. case "$randfunc" in
  1611. '')
  1612.     if $contains "^drand48\$" libc.list >/dev/null 2>&1; then
  1613.         dflt="drand48"
  1614.         echo "Good, found drand48()."
  1615.     elif $contains "^random\$" libc.list >/dev/null 2>&1; then
  1616.         dflt="random"
  1617.         echo "OK, found random()."
  1618.     else
  1619.         dflt="rand"
  1620.         echo "Yick, looks like I have to use rand()."
  1621.     fi
  1622.     echo " "
  1623.     ;;
  1624. *)
  1625.     dflt="$randfunc"
  1626.     ;;
  1627. esac
  1628. cont=true
  1629. while $test "$cont"; do
  1630.     rp="Use which function to generate random numbers? [$dflt]"
  1631.     $echo $n "$rp $c"
  1632.     . myread
  1633.     if $test "$ans" = "$dflt"; then
  1634.         : null
  1635.     else
  1636.         nrandbits=''
  1637.     fi
  1638.     randfunc="$ans"
  1639.     if $contains "^$ans\$" libc.list >/dev/null 2>&1; then
  1640.         cont=''
  1641.     else
  1642.         dflt=n
  1643.         rp="Function $ans does not exists. Use that name anyway? [$dflt]"
  1644.         $echo $n "$rp $c"
  1645.         . myread
  1646.         dflt=rand
  1647.         case "$ans" in
  1648.             [yY]*) cont='';;
  1649.         esac
  1650.     fi
  1651.     case "$cont" in
  1652.     '')
  1653.         case "$randfunc" in
  1654.         drand48)
  1655.             mrand="drand48()"
  1656.             seedfunc="srand48"
  1657.             ;;
  1658.         rand*)
  1659.             case "$nrandbits" in
  1660.             '')
  1661.             echo "Checking to see how many bits your $randfunc() function produces..."
  1662.             $cat >try.c <<EOCP
  1663. #include <stdio.h>
  1664. main()
  1665. {
  1666.     register int i;
  1667.     register unsigned long tmp;
  1668.     register unsigned long max = 0L;
  1669.     extern long random();
  1670.  
  1671.     for (i=1000; i; i--) {
  1672.         tmp = (unsigned long)$randfunc();
  1673.         if (tmp > max) max = tmp;
  1674.     }
  1675.     for (i=0; max; i++)
  1676.         max /= 2;
  1677.     printf("%d\n",i);
  1678. }
  1679. EOCP
  1680.             if $cc try.c -o try >/dev/null 2>&1 ; then
  1681.             dflt=`try`
  1682.             else
  1683.             dflt='?'
  1684.             echo "(I can't seem to compile the test program...)"
  1685.             fi
  1686.             ;;
  1687.             *)
  1688.                 dflt="$nrandbits"
  1689.                 ;;
  1690.             esac
  1691.             rp="How many bits does your $randfunc() function produce? [$dflt]"
  1692.             $echo $n "$rp $c"
  1693.             . myread
  1694.             nrandbits="$ans"
  1695.             $rm -f try.c try
  1696.             mrand="($randfunc() / (double) ((1 << $nrandbits) -1))"
  1697.             seedfunc="srand"
  1698.             ;;
  1699.         *)
  1700.             dflt="31"
  1701.             rp="How many bits does your $randfunc() function produce? [$dflt]"
  1702.             $echo $n "$rp $c"
  1703.             . myread
  1704.             nrandbits="$ans"
  1705.             seedfunc="s$randfunc"
  1706.             mrand="($randfunc() / (double) ((1 << $nrandbits) -1))"
  1707.             if $contains "^$seedfunc\$" libc.list >/dev/null 2>&1; then
  1708.                 echo "(Using $seedfunc() to seed random generator)"
  1709.             else
  1710.                 echo "(Warning: no $seedfunc() to seed random generator)"
  1711.                 seedfunc=rand
  1712.             fi
  1713.             ;;
  1714.         esac
  1715.         ;;
  1716.     esac
  1717. done
  1718.  
  1719. : check for void type
  1720. echo " "
  1721. $cat <<EOM
  1722. Checking to see how well your C compiler groks the void type...
  1723.  
  1724.   Support flag bits are:
  1725.     1: basic void declarations.
  1726.     2: arrays of pointers to functions returning void.
  1727.     4: operations between pointers to and addresses of void functions.
  1728.     8: generic void pointers.
  1729.  
  1730. EOM
  1731. case "$voidflags" in
  1732. '')
  1733.     $cat >try.c <<'EOCP'
  1734. #if TRY & 1
  1735. void main() {
  1736. #else
  1737. main() {
  1738. #endif
  1739.     extern void moo();    /* function returning void */
  1740.     void (*goo)();        /* ptr to func returning void */
  1741. #if TRY & 8
  1742.     void *hue;        /* generic ptr */
  1743. #endif
  1744. #if TRY & 2
  1745.     void (*foo[10])();
  1746. #endif
  1747.  
  1748. #if TRY & 4
  1749.     if(goo == moo) {
  1750.         exit(0);
  1751.     }
  1752. #endif
  1753.     exit(0);
  1754. }
  1755. EOCP
  1756.     if $cc -S -DTRY=$defvoidused try.c >.out 2>&1 ; then
  1757.         voidflags=$defvoidused
  1758.         echo "It appears to support void."
  1759.         if $contains warning .out >/dev/null 2>&1; then
  1760.             echo "However, you might get some warnings that look like this:"
  1761.             $cat .out
  1762.         fi
  1763.     else
  1764.         echo "Hmm, your compiler has some difficulty with void.  Checking further..."
  1765.         if $cc -S -DTRY=1 try.c >/dev/null 2>&1 ; then
  1766.             echo "It supports 1..."
  1767.             if $cc -S -DTRY=3 try.c >/dev/null 2>&1 ; then
  1768.                 echo "It also supports 2..."
  1769.                 if $cc -S -DTRY=7 try.c >/dev/null 2>&1 ; then
  1770.                     voidflags=7
  1771.                     echo "And it supports 4 but not 8 definitely."
  1772.                 else
  1773.                     echo "It doesn't support 4..."
  1774.                     if $cc -S -DTRY=11 try.c >/dev/null 2>&1 ; then
  1775.                         voidflags=11
  1776.                         echo "But it supports 8."
  1777.                     else
  1778.                         voidflags=3
  1779.                         echo "Neither does it support 8."
  1780.                     fi
  1781.                 fi
  1782.             else
  1783.                 echo "It does not support 2..."
  1784.                 if $cc -S -DTRY=13 try.c >/dev/null 2>&1 ; then
  1785.                     voidflags=13
  1786.                     echo "But it supports 4 and 8."
  1787.                 else
  1788.                     if $cc -S -DTRY=5 try.c >/dev/null 2>&1 ; then
  1789.                         voidflags=5
  1790.                         echo "And it supports 4 but haven't heard about 8."
  1791.                     else
  1792.                         echo "However it supports 8 but not 4."
  1793.                     fi
  1794.                 fi
  1795.             fi
  1796.         else
  1797.             echo "There is no support at all for void."
  1798.             voidflags=0
  1799.         fi
  1800.     fi
  1801. esac
  1802. dflt="$voidflags";
  1803. rp="Your void support flags add up to what? [$dflt]"
  1804. $echo $n "$rp $c"
  1805. . myread
  1806. voidflags="$ans"
  1807. $rm -f try.* .out
  1808.  
  1809. : preserve RCS keywords in files with variable substitution, grrr
  1810. Log='$Log'
  1811. Header='$Header'
  1812. Id='$Id'
  1813.  
  1814. : determine where public executables go
  1815. case "$bin" in
  1816. '')
  1817.     dflt=`loc . /bin /usr/local/bin /usr/lbin /usr/local /usr/bin`
  1818.     ;;
  1819. *)  dflt="$bin"
  1820.     ;;
  1821. esac
  1822. cont=true
  1823. while $test "$cont" ; do
  1824.     echo " "
  1825.     rp="Where do you want to put the public executables? (~name ok) [$dflt]"
  1826.     $echo $n "$rp $c"
  1827.     . myread
  1828.     bin="$ans"
  1829.     bin=`filexp $bin`
  1830.     if test -d $bin; then
  1831.     cont=''
  1832.     else
  1833.     dflt=n
  1834.     rp="Directory $bin doesn't exist.  Use that name anyway? [$dflt]"
  1835.     $echo $n "$rp $c"
  1836.     . myread
  1837.     dflt=''
  1838.     case "$ans" in
  1839.     y*) cont='';;
  1840.     esac
  1841.     fi
  1842. done
  1843.  
  1844. : find out how to generate dependencies
  1845. echo " "
  1846. echo "Checking how to generate makefile dependencies on your machine..."
  1847. toplev=`cd ..;pwd`
  1848. ccinc="-I. -I$toplev -I$toplev/libray -I$toplev/libshade $urtinc"
  1849. $cat >dep.c <<'EOCP'
  1850. #include "dep.h"
  1851. EOCP
  1852. $cat >dep.h <<'EOCP'
  1853.  
  1854. EOCP
  1855. case "$mkdep" in
  1856. '')
  1857.     ;;
  1858. *)
  1859.     if test -x "$mkdep" &&
  1860.         $mkdep dep.c >dep.out 2>/dev/null &&
  1861.         $contains 'dep\.o:.*dep\.h' dep.out >/dev/null 2>&1
  1862.     then
  1863.         echo "$mkdep works."
  1864.     else
  1865.         mkdep=
  1866.     fi
  1867. esac
  1868.  
  1869. case "$mkdep" in
  1870. '')
  1871.     $spitshell > ../mkdep <<EOM
  1872. $startsh
  1873. for srcfile
  1874. do
  1875.     $cpp -M $ccinc $cppflags \$srcfile
  1876. done
  1877. EOM
  1878.     mkdep=$toplev/mkdep
  1879.     chmod +x $mkdep
  1880.     $eunicefix $mkdep
  1881.     if $mkdep dep.c >dep.out 2>/dev/null &&
  1882.         $contains 'dep\.o:.*dep\.h' dep.out >/dev/null 2>&1
  1883.     then
  1884.         echo "Looks like we can use $cpp -M."
  1885.     else
  1886.         mkdep=
  1887.     fi
  1888.     ;;
  1889. esac
  1890.  
  1891. case "$mkdep" in
  1892. '')
  1893.     $spitshell >../mkdep <<EOS
  1894. $startsh
  1895. for srcfile
  1896. do
  1897.     case "\$srcfile" in
  1898.     *.c) c='.c';;
  1899.     *.y) c='.y';;
  1900.     *.l) c='.l';;
  1901.     esac
  1902.     filebase=\`basename \$srcfile \$c\`
  1903.     < \$srcfile $cpp $cppminus $cppflags $ccinc | \\
  1904.     $sed -e '/^# *[0-9]/!d' \\
  1905.         -e 's/^.*"\(.*\)".*\$/'\$filebase'.o: \1/' \\
  1906.         -e 's|: \./|: |' \\
  1907.         -e 's|: *$|: '\$srcfile'|' | \\
  1908.     $grep -v '^#' | $sort | $uniq
  1909. done
  1910. EOS
  1911.     mkdep=$toplev/mkdep
  1912.     chmod +x $mkdep
  1913.     $eunicefix $mkdep
  1914.     if $mkdep dep.c >dep.out 2>/dev/null &&
  1915.         $contains 'dep\.o:.*dep\.h' dep.out >/dev/null 2>&1
  1916.     then
  1917.         echo "A shell script using $cpp does the trick."
  1918.     else
  1919.         echo "$cpp doesn't seem to be any use at all."
  1920.         $spitshell >../mkdep <<EOS
  1921. $startsh
  1922. for srcfile
  1923. do
  1924.     case "\$srcfile" in
  1925.     *.c) c='.c';;
  1926.     *.y) c='.y';;
  1927.     *.l) c='.l';;
  1928.     esac
  1929.     filebase=\`basename \$srcfile \$c\`
  1930.     echo \$filebase.o: \$srcfile
  1931.     $grep '^#[  ]*include' \$srcfile /dev/null |
  1932.     $sed -e 's/#[   ]*include[  ]*//' \\
  1933.         -e 's,<\(.*\)>,"/usr/include/\1",' \\
  1934.         -e 's/:[^"]*"\([^"]*\)".*/: \1/' \\
  1935.         -e 's/\.c:/\.o:/'
  1936. done
  1937. EOS
  1938.         mkdep=$toplev/mkdep
  1939.         chmod +x $mkdep
  1940.         $eunicefix $mkdep
  1941.         if $mkdep dep.c >dep.out 2>/dev/null &&
  1942.             $contains 'dep\.o:.*dep\.h' dep.out >/dev/null 2>&1
  1943.         then
  1944.             cat << EOM
  1945.  
  1946. I can use a script with grep instead, but it will make some incorrect
  1947. dependencies, since it doesn't understand about conditional compilation.
  1948. Moreover, some dependencies may be missing, because scanning won't be
  1949. a recursive process.
  1950. If you have a program which generates makefile dependencies, you may want
  1951. to use it.  If not, you can use the script and edit the Makefile by hand
  1952. if you need to.
  1953. EOM
  1954.         else
  1955.             mkdep=
  1956.             cat << EOM
  1957.  
  1958. I can't seem to generate makefile dependencies at all!  Perhaps you have a
  1959. program that does?  If you don't, you might look at the mkdep script to
  1960. see if you can create one which works.
  1961. EOM
  1962.         fi
  1963.     fi
  1964. esac
  1965. cont=true
  1966. dflt="$mkdep"
  1967. while $test "$cont" ; do
  1968.     echo " "
  1969. rp="Name of program to make makefile dependencies? [$dflt]"
  1970. $echo $n "$rp $c"
  1971. . myread
  1972. mkdep="$ans"
  1973. mkdep=`filexp $mkdep`
  1974. if test -f "$mkdep"; then
  1975.     cont=''
  1976. else
  1977.     dflt=n
  1978.     rp="$mkdep doesn't exist.  Use that name anyway? [$dflt]"
  1979.     $echo $n "$rp $c"
  1980.     . myread
  1981.     dflt=''
  1982.     case "$ans" in
  1983.     y*) cont='';;
  1984.     esac
  1985. fi
  1986. done
  1987. $rm -f dep.c dep.h dep.o dep.out
  1988. : see if ar generates random libraries by itself
  1989. echo " "
  1990. echo "Checking how to generate random libraries on your machine..."
  1991. ar rc ran.a /dev/null
  1992. if ar ts ran.a >/dev/null 2>&1; then
  1993.     echo "ar appears to generate random libraries itself."
  1994.     orderlib=false
  1995.     ranlib=":"
  1996. else
  1997.     if test -f /usr/bin/ranlib; then
  1998.         ranlib=/usr/bin/ranlib
  1999.     elif test -f /bin/ranlib; then
  2000.         ranlib=/bin/ranlib
  2001.     fi
  2002.  
  2003.     if test -n "$ranlib"; then
  2004.         echo "your system has $ranlib; we'll use that."
  2005.         orderlib=false
  2006.     else
  2007.         echo "your system doesn't seem to support random libraries"
  2008.         echo "so we'll use lorder and tsort to order the libraries."
  2009.         orderlib=true
  2010.         ranlib=":"
  2011.     fi
  2012. fi
  2013.  
  2014. : determine compiler compiler
  2015. case "$bison" in
  2016. /*) dflt="bison -y";;
  2017. *) case "$yacc" in
  2018.         '') dflt=yacc;;
  2019.         *)  dflt="$yacc";;
  2020.     esac
  2021.     ;;
  2022. esac
  2023. cont=true
  2024.     echo " "
  2025. rp="Which compiler compiler (yacc or bison -y) will you use? [$dflt]"
  2026. $echo $n "$rp $c"
  2027. . myread
  2028. case "$ans" in
  2029. '') ans="$dflt";;
  2030. *bis*) ans="bison -y";;
  2031. *yac*) ans="yacc";;
  2032. esac
  2033. yacc="$ans"
  2034.  
  2035. echo " "
  2036. echo "End of configuration questions."
  2037. echo " "
  2038.  
  2039. : create config.sh file
  2040. echo " "
  2041. if test -d ../UU; then
  2042.     cd ..
  2043. fi
  2044. echo "Creating config.sh..."
  2045. $spitshell <<EOT >config.sh
  2046. $startsh
  2047. # config.sh
  2048. # This file was produced by running the Configure script.
  2049.  
  2050. d_eunice='$d_eunice'
  2051. d_xenix='$d_xenix'
  2052. d_bsd='$d_bsd'
  2053. define='$define'
  2054. eunicefix='$eunicefix'
  2055. loclist='$loclist'
  2056. expr='$expr'
  2057. awk='$awk'
  2058. sed='$sed'
  2059. echo='$echo'
  2060. cat='$cat'
  2061. chgrp='$chgrp'
  2062. chmod='$chmod'
  2063. chown='$chown'
  2064. rm='$rm'
  2065. mv='$mv'
  2066. cp='$cp'
  2067. tail='$tail'
  2068. tr='$tr'
  2069. mkdir='$mkdir'
  2070. sort='$sort'
  2071. uniq='$uniq'
  2072. grep='$grep'
  2073. trylist='$trylist'
  2074. test='$test'
  2075. inews='$inews'
  2076. egrep='$egrep'
  2077. more='$more'
  2078. pg='$pg'
  2079. Mcc='$Mcc'
  2080. vi='$vi'
  2081. mail='$mail'
  2082. bison='$bison'
  2083. cpp='$cpp'
  2084. perl='$perl'
  2085. Log='$Log'
  2086. Header='$Header'
  2087. Id='$Id'
  2088. bin='$bin'
  2089. contains='$contains'
  2090. cppstdin='$cppstdin'
  2091. cppminus='$cppminus'
  2092. d_bzero='$d_bzero'
  2093. d_cbrt='$d_cbrt'
  2094. d_index='$d_index'
  2095. d_memset='$d_memset'
  2096. d_popen='$d_popen'
  2097. d_rusage='$d_rusage'
  2098. d_times='$d_times'
  2099. clocktype='$clocktype'
  2100. i_string='$i_string'
  2101. strings='$strings'
  2102. i_sysresrc='$i_sysresrc'
  2103. i_systypes='$i_systypes'
  2104. i_time='$i_time'
  2105. i_systime='$i_systime'
  2106. i_systimek='$i_systimek'
  2107. timeincl='$timeincl'
  2108. inhdr='$inhdr'
  2109. inlibc='$inlibc'
  2110. libs='$libs'
  2111. models='$models'
  2112. split='$split'
  2113. small='$small'
  2114. medium='$medium'
  2115. large='$large'
  2116. huge='$huge'
  2117. ccflags='$ccflags'
  2118. ldflags='$ldflags'
  2119. cc='$cc'
  2120. cppflags='$cppflags'
  2121. optimize='$optimize'
  2122. n='$n'
  2123. c='$c'
  2124. orderlib='$orderlib'
  2125. ranlib='$ranlib'
  2126. package='$package'
  2127. randfunc='$randfunc'
  2128. mrand='$mrand'
  2129. seedfunc='$seedfunc'
  2130. nrandbits='$nrandbits'
  2131. spitshell='$spitshell'
  2132. shsharp='$shsharp'
  2133. sharpbang='$sharpbang'
  2134. startsh='$startsh'
  2135. sysman='$sysman'
  2136. voidflags='$voidflags'
  2137. defvoidused='$defvoidused'
  2138. yacc='$yacc'
  2139. d_urt='$d_urt'
  2140. urtinc='$urtinc'
  2141. urtlib='$urtlib'
  2142. i_stdlib='$i_stdlib'
  2143. libc='$libc'
  2144. mkdep='$mkdep'
  2145. CONFIG=true
  2146. EOT
  2147.  
  2148. CONFIG=true
  2149.  
  2150. echo " "
  2151. dflt=''
  2152. fastread=''
  2153. echo "If you didn't make any mistakes, then just type a carriage return here."
  2154. rp="If you need to edit config.sh, do it as a shell escape here:"
  2155. $echo $n "$rp $c"
  2156. . UU/myread
  2157. case "$ans" in
  2158. '') ;;
  2159. *) : in case they cannot read
  2160.     eval $ans;;
  2161. esac
  2162. . ./config.sh
  2163.  
  2164. echo " "
  2165. echo "Doing variable substitutions on .SH files..."
  2166. if test -f MANIFEST; then
  2167.     set x `awk '{print $1}' <MANIFEST | $grep '\.SH'`
  2168. else
  2169.     set x `find . -name "*.SH" -print`
  2170. fi
  2171. shift
  2172. case $# in
  2173. 0) set x *.SH; shift;;
  2174. esac
  2175. if test ! -f $1; then
  2176.     shift
  2177. fi
  2178. for file in $*; do
  2179.     case "$file" in
  2180.     */*)
  2181.     dir=`$expr X$file : 'X\(.*\)/'`
  2182.     file=`$expr X$file : 'X.*/\(.*\)'`
  2183.     (cd $dir && . $file)
  2184.     ;;
  2185.     *)
  2186.     . $file
  2187.     ;;
  2188.     esac
  2189. done
  2190. if test -f config.h.SH; then
  2191.     if test ! -f config.h; then
  2192.     : oops, they left it out of MANIFEST, probably, so do it anyway.
  2193.     . config.h.SH
  2194.     fi
  2195. fi
  2196.  
  2197. if $contains '^depend:' Makefile >/dev/null 2>&1; then
  2198.     dflt=n
  2199.     $cat <<EOM
  2200.  
  2201. Now you need to generate make dependencies by running "make depend".
  2202. You might prefer to run it in background: "make depend > makedepend.out &"
  2203. It can take a while, so you might not want to run it right now.
  2204.  
  2205. EOM
  2206.     rp="Run make depend now? [$dflt]"
  2207.     $echo $n "$rp $c"
  2208.     . UU/myread
  2209.     case "$ans" in
  2210.     y*) make depend
  2211.     echo "Now you must run a make."
  2212.     ;;
  2213.     *)  echo "You must run 'make depend' then 'make'."
  2214.     ;;
  2215.     esac
  2216. elif test -f Makefile; then
  2217.     echo " "
  2218.     echo "Now you must run a make."
  2219. else
  2220.     echo "Done."
  2221. fi
  2222.  
  2223. $rm -f kit*isdone
  2224. : the following is currently useless
  2225. cd UU && $rm -f $rmlist
  2226. : since this removes it all anyway
  2227. cd .. && $rm -rf UU
  2228. : end of Configure
  2229.